-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(tracing): Favour client options tracePropagationTargets #8399
Conversation
size-limit report 📦
|
shouldCreateSpanForRequest, | ||
_experiments, | ||
} = this.options; | ||
|
||
const tracePropagationTargets = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, does it make sense that the top-level options take precedence? 🤔 I think I would expect the options that are passed directly to the integration to "win", so:
this.options.tracePropagationTargets || (clientOptions && clientOptions.tracePropagationTargets);
? Not a big thing, as I don't expect this to happen too often, though :) So feel free to ignore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a fair perspective actually. Let's discuss this at our meeting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on our meeting we've made two decisions.
- We'll be combining the arrays of both top level and integration set
tracePropagationTargets
- We'll be emitting a warning when both values are set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detailed below I decided against the combining array approach, but added the warning in b098188
I experimented with merging in two arrays - but found it would be confusing to users because of the deprecated Here's a git patch with the logic I was testing with diff --git a/packages/tracing-internal/src/browser/browsertracing.ts b/packages/tracing-internal/src/browser/browsertracing.ts
index 202f4fe7a..755aae6a3 100644
--- a/packages/tracing-internal/src/browser/browsertracing.ts
+++ b/packages/tracing-internal/src/browser/browsertracing.ts
@@ -177,9 +177,15 @@ export class BrowserTracing implements Integration {
private _collectWebVitals: () => void;
+ // See `tracePropagationTargets` in `setupOnce` for why this is commented out.
+ // private _hasSetTracePropagationTargets: boolean = false;
+
public constructor(_options?: Partial<BrowserTracingOptions>) {
addTracingExtensions();
+ // eslint-disable-next-line deprecation/deprecation
+ // this._hasSetTracePropagationTargets = !!(_options && (_options.tracePropagationTargets || _options.tracingOrigins));
+
this.options = {
...DEFAULT_BROWSER_TRACING_OPTIONS,
..._options,
@@ -229,8 +235,23 @@ export class BrowserTracing implements Integration {
_experiments,
} = this.options;
- const tracePropagationTargets =
- (clientOptions && clientOptions.tracePropagationTargets) || this.options.tracePropagationTargets;
+ const clientOptionsTracePropagationTargets = clientOptions && clientOptions.tracePropagationTargets;
+ // There are three ways to configure tracePropagationTargets:
+ // 1. via top level client option `tracePropagationTargets`
+ // 2. via BrowserTracing option `tracePropagationTargets`
+ // 3. via BrowserTracing option `tracingOrigins` (deprecated)
+ //
+ // To avoid confusion, favour top level client option `tracePropagationTargets`, and fallback to
+ // BrowserTracing option `tracePropagationTargets` and then `tracingOrigins` (deprecated).
+ // This is done as it minimizes bundle size (we don't have to have undefined checks).
+ //
+ // If both 1 and either one of 2 or 3 are set (from above), we log out a warning.
+ const tracePropagationTargets = clientOptionsTracePropagationTargets || this.options.tracePropagationTargets;
+ // This warning will be in a future release after 7.57.0 when we formally deprecated the
+ // BrowserTracing`tracePropagationTargets` option.
+ // if (__DEBUG_BUILD__ && this._hasSetTracePropagationTargets && clientOptionsTracePropagationTargets) {
+ // logger.warn('[Tracing] You have set options for tracePropagationTargets in BrowserTracing and top level `Sentry.init`. The SDK is defaulting to use value for top level `tracePropagationTargets` in client.');
+ // }
instrumentRouting(
(context: TransactionContext) => { I'm only going to be adding a warning as a result. |
ref #8352
As we work toward adding tracing without performance support, this PR updates the
BrowserTracing
integration to use and favour the top leveltracePropagationTargets
option if it exists.This option was made top level in #8395
tracePropagationTargets
is now part of the unified API for distributed tracing. It's also expected that electron/react native will behave the same way as well. This also leaves us the flexibility to extract tracing out of BrowserTracing, or create a new integration that just does tracing but no performance monitoring.We can make sure this migration is smooth and easy to understand with a good set of docs, which is what I will be working on next. In these docs changes, we'll be updating the automatic instrumentation sections, and formally documented
tracePropagationTargets
as a high level option.